#define _CRT_SECURE_NO_WARNINGS	

/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     struct ListNode *next;
 * };
 */
int arr[32];
typedef struct ListNode ListNode;
int getDecimalValue(struct ListNode* head)
{
    int count = 0;
    ListNode* pcur = head;
    while (pcur != NULL)
    {
        arr[count] = pcur->val;
        count++;
        pcur = pcur->next;
    }
    int tmp = 1;
    int sum = 0;
    for (int i = count - 1; i >= 0; i--)
    {
        sum += tmp * arr[i];
        tmp *= 2;
    }
    return sum;
}